package itcast.web.servlet;

import itcast.domain.Drom;
import itcast.domain.Studnet;
import itcast.service.Drom_manageService;
import itcast.service.StudentService;
import itcast.service.impl.Drom_manageServiceImpl;
import itcast.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet("/findStudent_manageDataServlet")
public class FindStudent_manageDataServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //1.设置编码
        request.setCharacterEncoding("utf-8");
        //2.获取条件查询参数
        Map<String,String[]> condition=request.getParameterMap();


        //3.调用Service查询
        StudentService service=new StudentServiceImpl();
        List<Studnet> studnets=service.findstudent_manageByDate(condition);

        request.setAttribute("students",studnets);

        //3.跳转到查询所有的Servlet
        request.getRequestDispatcher("/dromitory/student_manage.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request,response);
    }
}
